package gr.atc.epart.googlewrapper.moderator;

import gr.atc.epart.googlewrapper.moderator.ModeratorTopic;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class ModeratorSeries
{
	public static final String PLUS_VOTES = "plusVotes";
	public static final String MINUS_VOTES = "minusVotes";
	public static final String NONE_VOTES = "noneVotes";
	
	private int _seriesId;
	private String _name;
	private String _description;
	private int	_numOfTopics;
	private int	_numOfSubmissions; 
	private int	_numOfVideoSubmissions;
	private int	_numOfUsers;
	
	private boolean	_videoSubmissionAllowed;
	
	private HashMap<String, Integer> _counters;
	private ArrayList<ModeratorTopic>	_topics;
	  
	
	
	public ModeratorSeries(int seriesId)
	{
		_seriesId = seriesId;
		_counters = new HashMap<String, Integer>();
		_topics = new ArrayList<ModeratorTopic>();
		
		_counters.put(PLUS_VOTES, 0);
		_counters.put(MINUS_VOTES, 0);
		_counters.put(NONE_VOTES, 0);
	}
	
	public int getSeriesId()
	{
		return _seriesId;
	}
	
	public void setName(String name)
	{
		_name = name;
	}
	
	public String getName()
	{
		return _name;
	}
		
	public void setDescription(String description)
	{
		_description = description; 	
	}
	
	public String getDescription()
	{
		return _description; 
	}

	public void setNumOfTopics(int numofTopics)
	{
		_numOfTopics = numofTopics;
	}
	
	public int getNumOfTopics()
	{
		return _numOfTopics;
	}

	public void setNumOfSubmissions(int numofSubmissions)
	{
		_numOfSubmissions = numofSubmissions;
	}
	
	public int getNumOfSubmissions()
	{
		return _numOfSubmissions;
	}

	public void setNumOfVideoSubmissions(int numofVideoSubmissions)
	{
		_numOfVideoSubmissions= numofVideoSubmissions;
	}
	
	public int getNumOfvideoSubmissions()
	{
		return _numOfVideoSubmissions;
	}

	public void setNumOfUsers(int numofUsers)
	{
		_numOfUsers = numofUsers;
	}
	
	public int getNumOfUsers()
	{
		return _numOfUsers;
	}
	
	public boolean getVideoSumbissionAllowed()
	{
		return _videoSubmissionAllowed;
	}

	public void setVideoSumbissionAllowed(boolean allowed)
	{
		 _videoSubmissionAllowed = allowed;
	}

	public void setcounter(String tag,int value)
	{
		if (_counters.containsKey(tag))
		{
			_counters.put(tag, value);
		}
	}
	
	public int getCounter(String tag) throws Exception
	{
		if (_counters.containsKey(tag))
		{
			return _counters.get(tag);
		}
		else
		{
			throw new Exception("Counter name not be recognised");
		}
			
	}

	public void addTopic(ModeratorTopic	topic)
	{
		_topics.add(topic);
	}

	public boolean hasTopics()
	{
		return !_topics.isEmpty();
	}
	
	public boolean shouldRetrieveTopics()
	{
		//return (getNumOfTopics()>0 && ! hasTopics());
		return (_topics.size() != _numOfTopics );
	}
	
	public ArrayList<ModeratorTopic> getTopicList()
	{
		return _topics;
	}

	public void removeAllTopics()
	{
		// remove all topics...
		_topics.clear();
		// which means...no sumbisions
		_numOfSubmissions=0;
		_numOfVideoSubmissions=0;
		_numOfUsers = 0;
		
		// ..and no votes!
		_counters.put(PLUS_VOTES, 0);
		_counters.put(MINUS_VOTES, 0);
		_counters.put(NONE_VOTES, 0);
	}
}
